const std = @import("std");
const awtk = @import("awtk");
const object = @import("../object.zig");

const c = awtk.c;

pub const Gender = enum {
    Male,
    Female,
};

pub const User = struct {
    name: awtk.String = undefined,
    age: u8 = 0,
    gender: Gender = .Male,

    pub fn init(self: *User) void {
        std.log.debug("{s}.{s}", .{ awtk.baseTypeName(@This()), @src().fn_name });
        self.name = awtk.String.init(32);
        self.name.setStr("") catch unreachable;
    }

    pub fn deinit(self: *User) void {
        std.log.debug("{s}.{s}", .{ awtk.baseTypeName(@This()), @src().fn_name });
        self.name.deinit();
    }

    pub fn format(self: User, writer: *std.Io.Writer) !void {
        try writer.print("name: {s}, age: {d}, gender: {s}", .{ self.name.str(), self.age, @tagName(self.gender) });
    }

    pub fn setName(self: *User, a_name: []const u8) !void {
        try self.name.setStr(a_name);
    }

    pub fn isAdult(age: u8) bool {
        return age >= 18;
    }
};
